import {Grade} from "./models/Grade";
import {IStudent, Student} from "./models/Student";
import {MyClass} from "./models/MyClass";
import{Subject,SubjectType} from "./models/Subject";
import{ITeacher,Teacher} from "./models/Teacher"
import {ysReadline, ysReadlineClose} from "./read";
import {Controler} from "./models/Controler";

function case001(){
  const _none =  new Grade(SubjectType.None, 100)
  if (_none.toString() !== "没有成绩"){
    console.log("None 类型 toString 异常")
  }
  console.log(_none.toString())

  const _chinese = new Grade(SubjectType.Chinese, 90)
  if (_chinese.toString() !== "良"){
    console.log("Chinese 类型 toString 异常")
  }
  console.log(_chinese.toString())
}
function newStudent(stuId:number,name:string,gradeChinese:number,gradeEnglish:number,gradeMath:number,gradePhysical:number,gradeChemistry:number,gradeBiology:number){
  const _student = new Student(stuId,name)
  _student.setGradeByType(SubjectType.Chinese,gradeChinese)
  _student.setGradeByType(SubjectType.English,gradeEnglish)
  _student.setGradeByType(SubjectType.Math,gradeMath)
  _student.setGradeByType(SubjectType.Physical,gradePhysical)
  _student.setGradeByType(SubjectType.Chemistry,gradeChemistry)
  _student.setGradeByType(SubjectType.Biology,gradeBiology)
  return _student
}

function newTeacher(classId:number,Chinese:string,English:string,Math:string,Physical:string,Chemistry:string,Biology:string){
  const _teacher = new Teacher(classId)
  _teacher.setSubject(new Subject(SubjectType.Chinese,Chinese))
  _teacher.setSubjectByType(SubjectType.English,English)
  _teacher.setSubjectByType(SubjectType.Math,Math)
  _teacher.setSubjectByType(SubjectType.Physical,Physical)
  _teacher.setSubjectByType(SubjectType.Chemistry,Chemistry)
  _teacher.setSubjectByType(SubjectType.Biology,Biology)
  return _teacher
}
function case002(){
  const _student1 = newStudent(2,"小明",92,94,98,100,87,92)
  const _student2 = newStudent(1,"小华",72,56,65,81,79,52)

  console.log(_student1)
  console.log(_student2)

  _student2.setGradeByType(SubjectType.English,70)
  console.log(_student2)
  console.log(_student2.getGrade(SubjectType.English)!.toString())
}

function case003(){
  const _student1 = newStudent(2,"小明",92,94,98,100,87,92)
  const _student2 = newStudent(1,"小华",72,56,65,81,79,52)

  const _class1 = new MyClass(1)
  _class1.addStudents([
    _student1,
    _student2
  ])
  _class1.showGrade()
}


function case004(){
  const _student1 = newStudent(1,"小明",92,94,98,100,87,92)
  const _student2 = newStudent(2,"小华",72,56,65,81,79,52)
  const _class1 = new MyClass(1)
  const _teacher1 = newTeacher(_class1.id,"老王","老张","老赵","老钱","老孙","老李")
  _class1.addTeacher(_teacher1)
  _class1.addStudents([
    _student1,
    _student2
  ])
  _class1.showSubject()
  _class1.showGrade()


  const _student3 = newStudent(1,"小红",75,64,52,88,73,85)
  const _student4 = newStudent(2,"小虎",86,76,92,74,84,58)
  const _student5 = newStudent(3,"小军",92,86,94,65,67,95)
    const _class2= new MyClass(2)
  const _teacher2 = newTeacher(_class2.id,"小王","小张","小赵","小钱","小孙","小李")
  _class2.addTeacher(_teacher2)
  _class2.addStudents([
    _student3,
    _student4,
    _student5
  ])
  _class2.showSubject()
  _class2.showGrade()

}

function case005(){
  const c = new Controler()
  c.run()
}

async function case100() {
  let msg = await ysReadline("第一个读取：")
  console.log(msg)

  msg = await ysReadline("第二个读取：")
  console.log(msg)

  ysReadlineClose()
}

case005();
